<template>
  <div class="app-container">
    <div class="Search">
      <!--工具条-->
      <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
        <el-form :inline="true" :model="query">

          <el-form-item v-has="'PLATFROM_TENANT_QUERY'">
            <el-cascader ref="tenantTree" placeholder="所属租户" :props="tenantProps" :options="tenantOptions"
              @change="selectTenant" clearable collapse-tags filterable></el-cascader>
          </el-form-item>

          <el-form-item>
            <el-cascader ref="organTree" placeholder="所属组织" :props="props" :options="organOptions" @change="selectOrgan"
              collapse-tags clearable filterable></el-cascader>
          </el-form-item>
          <el-form-item>
            <el-input v-model="query.params.name" clearable placeholder="商户名称" />
          </el-form-item>
          <el-form-item>
            <el-select v-model="query.params.type" clearable placeholder="商户类型">
              <el-option v-for="item in query.merchantTypeOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-select v-model="query.params.isMain" clearable placeholder="是否主商户">
              <el-option v-for="item in query.isMainOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="fetchData">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="success" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </div>
    <div class="block">
      <el-table v-loading="listLoading" :data="list" element-loading-text="Loading" border fit highlight-current-row
        center>
        <el-table-column align="center" label="序号" width="95">
          <template slot-scope="scope">
            {{ scope.$index }}
          </template>
        </el-table-column>
        <el-table-column label="商户名称" width="200">
          <template slot-scope="scope">
            {{ scope.row.name }}
          </template>
        </el-table-column>
        <el-table-column label="商户类型" width="110" prop="type" :formatter="merchantType" />
        <el-table-column label="组织" width="110">
          <template slot-scope="scope">
            {{ scope.row.organName }}
          </template>
        </el-table-column>
        <el-table-column label="是否主商户" width="110" prop="type" :formatter="isMain" />
        <el-table-column label="绑定用户" width="110">
          <template slot-scope="scope">
            {{ scope.row.userName }}
          </template>
        </el-table-column>
        <el-table-column label="合伙方式" width="110" prop="type" :formatter="cooperationMode" />
        <el-table-column label="默认分润比例" width="160">
          <template slot-scope="scope">
            {{ scope.row.profitSharingRate }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="created_at" label="操作" width="200">
          <template slot-scope="scope">
            <span class="el-tag el-tag--info el-tag--mini" style="cursor: pointer;"
              @click="handleEdit(scope.$index, scope.row)">
              修改
            </span>

            <span v-if="!scope.row.isSet" class="el-tag el-tag--danger el-tag--mini" style="cursor: pointer;"
              @click="handleDelete(scope.$index, scope.row)">
              删除
            </span>

            <span class="el-tag el-tag--info el-tag--mini" style="cursor: pointer;"
              @click="handleMerchantRegister(scope.$index, scope.row)">
              开通银行卡收款账户
            </span>

          </template>


        </el-table-column>
      </el-table>
    </div>
    <div class="block">
      <el-pagination :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
    </div>
    <div class="block">
      <!--弹框-->
      <el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogFormVisible">
        <el-form :model="form" :rules="merchantRules" ref="merchantForm" :inline="true" label-width="170px" align="left">
          <el-form-item label="商户名称" prop="name">
            <el-input v-model="form.name" suffix-icon="xxxx" placeholder="商户名称" auto-complete="off" />
          </el-form-item>
          <el-form-item label="默认分润比例" prop="profitSharingRate">
            <el-input type="number" step="0.01" v-model="form.profitSharingRate" placeholder="默认分润比例"
              auto-complete="off" />

          </el-form-item>
          <el-form-item label="商户类型" prop="type">
            <!-- ,1 企业商户，2, 个体商户， 3 个人商户 -->
            <el-select v-model="form.type" placeholder="商户类型">
              <el-option v-for="item in query.merchantTypeOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否主商户" prop="isMain">
            <el-select v-model="form.isMain" placeholder="是否主商户">
              <el-option v-for="item in query.isMainOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="合伙方式" prop="cooperationMode">
            <el-select v-model="form.cooperationMode" placeholder="合伙方式">
              <el-option v-for="item in query.cooperationModeOptions" :key="item.value" :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="绑定用户" required>
            <SelectTree id="id" ref="UserSelectTree" placeholder="设备类型" :props="props" :options="userOptionData"
              :value="userValueId" :clearable='false' @getValue="getUserValue($event)" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="handleEditSave('merchantForm')">确 定</el-button>
        </div>
      </el-dialog>

      <div class="block">
        <!--弹框-->
        <el-dialog :title="titleMap[dialogStatus]" :close-on-click-modal="false" width="85%"
          :visible.sync="dialogFormMerchantRegisterVisible">

          <el-steps :active="active">
            <el-step title="填写资料"></el-step>
            <el-step title="上传备案文件"></el-step>
            <el-step title="开通产品"></el-step>
            <el-step title="微信报备"></el-step>
            <el-step title="APP报备"></el-step>
          </el-steps>
          <el-divider></el-divider>
          <div v-if="active == 0">
            <el-form :inline="true" :label-position="labelPosition" ref="merchantEntryForm" :rules="merchantEntryRules"
              label-width="110px" :model="merchantEntry">
              <el-form-item label="子商户类型" prop="merchantType">
                <el-select v-model="merchantEntry.merchantType" placeholder="子商户类型">
                  <el-option v-for="item in query.merchantTypeOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item v-if="addForVisible" label="主键">
                <el-input v-model="merchantEntry.id" placeholder="主键" auto-complete="off" />
              </el-form-item>
              <el-form-item label="平台商编" prop="firstClassMerchantNo">
                <el-input v-model="merchantEntry.firstClassMerchantNo" placeholder="平台商编" auto-complete="off" />
              </el-form-item>
              <el-form-item label="子商户签约名" prop="signName">
                <el-input v-model="merchantEntry.signName" placeholder="子商户签约名" auto-complete="off" />
              </el-form-item>

              <el-form-item label="经营类别" prop="merchantCategory">

                <el-select v-model="merchantEntry.merchantCategory" placeholder="经营类别">
                  <el-option v-for="item in query.merchantCategoryOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="展示名（收银台展示）" prop="showName">
                <el-input v-model="merchantEntry.showName" placeholder="展示名（收银台展示）" auto-complete="off" />
              </el-form-item>
              <el-form-item label="网站网址" prop="webSite">
                <el-input v-model="merchantEntry.webSite" placeholder="网站网址" auto-complete="off" />
              </el-form-item>
              <el-form-item label="接入地址" prop="accessUrl">
                <el-input v-model="merchantEntry.accessUrl" placeholder="接入地址" auto-complete="off" />
              </el-form-item>
              <el-form-item label="法人名字" prop="legalPerson">
                <el-input v-model="merchantEntry.legalPerson" placeholder="法人名字" auto-complete="off" />
              </el-form-item>
              <el-form-item label="法人身份证号" prop="legalPersonId">
                <el-input v-model="merchantEntry.legalPersonId" placeholder="法人身份证号" auto-complete="off" />
              </el-form-item>
              <el-form-item label="组织机构代码" prop="orgNum">
                <el-input v-model="merchantEntry.orgNum" placeholder="组织机构代码" auto-complete="off" />
              </el-form-item>
              <el-form-item label="营业执照号" prop="businessLicense">
                <el-input v-model="merchantEntry.businessLicense" placeholder="营业执照号" auto-complete="off" />
              </el-form-item>
              <el-form-item label="区域编码" prop="regionCode">
                <el-input v-model="merchantEntry.regionCode" placeholder="区域编码" auto-complete="off" />
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType != 'PERSON'" label="行业类型编码" prop="industryTypeCode">
                <el-input v-model="merchantEntry.industryTypeCode" placeholder="行业类型编码" auto-complete="off" />
              </el-form-item>
              <el-form-item label="通讯地址" prop="address">
                <el-input v-model="merchantEntry.address" placeholder="通讯地址" auto-complete="off" />
              </el-form-item>
              <el-form-item label="联系人" prop="linkMan">
                <el-input v-model="merchantEntry.linkMan" placeholder="联系人" auto-complete="off" />
              </el-form-item>
              <el-form-item label="联系人手机号" prop="linkPhone">
                <el-input v-model="merchantEntry.linkPhone" placeholder="联系人手机号" auto-complete="off" />
              </el-form-item>
              <el-form-item label="联系邮箱" prop="email">
                <el-input v-model="merchantEntry.email" placeholder="联系邮箱" auto-complete="off" />
              </el-form-item>
              <el-form-item label="绑定手机" prop="bindMobile">
                <el-input v-model="merchantEntry.bindMobile" placeholder="绑定手机" auto-complete="off" />
              </el-form-item>
              <el-form-item label="结算卡联行号" prop="bankCode">
                <el-input v-model="merchantEntry.bankCode" placeholder="结算卡联行号" auto-complete="off" />
              </el-form-item>
              <el-form-item label="银行开户名" prop="accountName">
                <el-input v-model="merchantEntry.accountName" placeholder="银行开户名" auto-complete="off" />
              </el-form-item>
              <el-form-item label="银行开户账号" prop="accountNo">
                <el-input v-model="merchantEntry.accountNo" placeholder="银行开户账号" auto-complete="off" />
              </el-form-item>
              <el-form-item label="结算卡类型" prop="settleBankType">
                <el-select v-model="merchantEntry.settleBankType" placeholder="结算卡类型">
                  <el-option v-for="item in query.settleBankTypeOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="结算周期" prop="settlementPeriod">

                <el-select v-model="merchantEntry.settlementPeriod" placeholder="结算周期">
                  <el-option v-for="item in query.settlementPeriodOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="结算方式" prop="settlementMode">
                <el-select v-model="merchantEntry.settlementMode" placeholder="结算方式">
                  <el-option v-for="item in query.settlementModeOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="结算模式" prop="settleMode">

                <el-select v-model="merchantEntry.settleMode" placeholder="结算模式">
                  <el-option v-for="item in query.settleModeOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="授权使用大商户秘钥" prop="authorizationFlag">

                <el-select v-model="merchantEntry.authorizationFlag" placeholder="授权使用大商户秘钥">
                  <el-option v-for="item in query.authorizationFlagOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="客服联系电话" prop="servicePhone">
                <el-input v-model="merchantEntry.servicePhone" placeholder="客服联系电话" auto-complete="off" />
              </el-form-item>
              <el-form-item label="银联二维码" prop="unionPayQrCode">
                <el-input v-model="merchantEntry.unionPayQrCode" placeholder="银联二维码" auto-complete="off" />
              </el-form-item>
              <el-form-item label="需要开通POS功能（平台商需开通）" prop="needPosFunction">
                <el-select v-model="merchantEntry.needPosFunction" placeholder="需要开通POS功能（平台商需开通）">
                  <el-option v-for="item in query.needPosFunctionOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>
              <el-form-item v-if="merchantEntry.needPosFunction == 'true'" label="法人身份证开始日期" prop="idCardStartDate">
                <el-date-picker v-model="merchantEntry.idCardStartDate" align="right" type="date" placeholder="法人身份证开始日期"
                  format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
              <el-form-item v-if="merchantEntry.needPosFunction == 'true'" label="法人身份证结束日期" prop="idCardEndDate">
                <el-date-picker v-model="merchantEntry.idCardEndDate" align="right" type="date" placeholder="法人身份证结束日期"
                  format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
              <el-form-item v-if="merchantEntry.needPosFunction == 'true'" label="经营起始日期" prop="businessDateStart">
                <el-date-picker v-model="merchantEntry.businessDateStart" align="right" type="date" placeholder="经营起始日期"
                  format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
              <el-form-item v-if="merchantEntry.needPosFunction == 'true'" label="经营期限" prop="businessDateLimit">
                <el-date-picker v-model="merchantEntry.businessDateLimit" align="right" type="date" placeholder="经营期限"
                  format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
              <el-form-item v-if="merchantEntry.needPosFunction == 'true'" label="开户人身份证" prop="accountIdCard">
                <el-input v-model="merchantEntry.accountIdCard" placeholder="开户人身份证" auto-complete="off" />
              </el-form-item>
              <el-form-item v-if="merchantEntry.needPosFunction == 'true'" label="银联mcc码" prop="mcc">
                <el-input v-model="merchantEntry.mcc" placeholder="银联mcc码" auto-complete="off" />
              </el-form-item>
              <el-form-item label="是否同意协议" prop="agreeProtocol">
                <el-input v-model="merchantEntry.agreeProtocol" placeholder="是否同意协议" auto-complete="off" />
              </el-form-item>
              <el-form-item label="回调地址" prop="callbackUrl">
                <el-input v-model="merchantEntry.callbackUrl" placeholder="回调地址" auto-complete="off" />
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType != 'PERSON' && merchantEntry.settleBankType == 'TOPRIVATE'"
                label="结算人身份证开始日期" prop="settlementIdCardStartDate">
                <!--  <el-input v-model="merchantEntry.settlementIdCardStartDate" placeholder="结算人身份证开始日期"  auto-complete="off"/> -->

                <el-date-picker v-model="merchantEntry.settlementIdCardStartDate" align="right" type="date"
                  placeholder="结算人身份证开始日期" format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType != 'PERSON' && merchantEntry.settleBankType == 'TOPRIVATE'"
                label="结算人身份证结束日期" prop="settlementIdCardEndDate">

                <el-date-picker v-model="merchantEntry.settlementIdCardEndDate" align="right" type="date"
                  placeholder="结算人身份证结束日期" format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType != 'PERSON' && merchantEntry.settleBankType == 'TOPRIVATE'"
                label="结算人身份证号" prop="settlementIdCardNo">
                <el-input v-model="merchantEntry.settlementIdCardNo" placeholder="结算人身份证号" auto-complete="off" />
              </el-form-item>
              <el-form-item label="结算信息鉴权" prop="settlementAuth">

                <el-select v-model="merchantEntry.settlementAuth" placeholder="结算信息鉴权">
                  <el-option v-for="item in query.settlementAuthOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>

              <el-form-item label="备注">
                <el-input v-model="merchantEntry.remark" placeholder="备注" auto-complete="off" />
              </el-form-item>
            </el-form>
          </div>
          <div v-if="active == 1">

            <el-form :inline="true" :label-position="labelPosition" label-width="100px" ref="merchantOriginForm"
              :rules="merchantOriginRules" :model="merchantOrigin">
              <el-form-item label="身份证正面" prop="FRONT_OF_ID_CARD">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewFRONT_OF_ID_CARD" :on-remove="handleRemove"
                  :before-upload="handlePreviewFRONT_OF_ID_CARD" :before-remove="beforeRemove" :data='fileUloadParams'
                  :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item label="身份证反面" prop="BACK_OF_ID_CARD">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewBACK_OF_ID_CARD" :on-remove="handleRemove"
                  :before-upload="handlePreviewBACK_OF_ID_CARD" :before-remove="beforeRemove" :data='fileUloadParams'
                  :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType == 'ENTERPRISE'" label="税务登记证" prop="TAX_REG_CERTIFICATE">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewTAX_REG_CERTIFICATE" :on-remove="handleRemove"
                  :before-upload="handlePreviewTAX_REG_CERTIFICATE" :before-remove="beforeRemove" :data='fileUloadParams'
                  :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType == 'ENTERPRISE'" label="组织机构证" prop="ORG_CERTIFICATE">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewORG_CERTIFICATE" :on-remove="handleRemove"
                  :before-upload="handlePreviewORG_CERTIFICATE" :before-remove="beforeRemove" :data='fileUloadParams'
                  :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType == 'ENTERPRISE'" label="开户许可证"
                prop="PERMIT_FOR_BANK_ACCOUNT">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewPERMIT_FOR_BANK_ACCOUNT" :on-remove="handleRemove"
                  :before-upload="handlePreviewPERMIT_FOR_BANK_ACCOUNT" :before-remove="beforeRemove"
                  :data='fileUloadParams' :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType != 'PERSON'" label="营业执照" prop="BUSINESS_LICENSE">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewBUSINESS_LICENSE" :on-remove="handleRemove"
                  :before-upload="handlePreviewBUSINESS_LICENSE" :before-remove="beforeRemove" :data='fileUloadParams'
                  :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item label="门头照" prop="SIGN_BOARD">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewSIGN_BOARD" :on-remove="handleRemove" :before-upload="handlePreviewSIGN_BOARD"
                  :before-remove="beforeRemove" :data='fileUloadParams' :limit="1" :on-exceed="handleExceed"
                  :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item label="收银台照" prop="CHECKOUT_COUNTER">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewCHECKOUT_COUNTER" :on-remove="handleRemove"
                  :before-upload="handlePreviewCHECKOUT_COUNTER" :before-remove="beforeRemove" :data='fileUloadParams'
                  :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item label="室内照" prop="INTERIOR_PHOTO">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewINTERIOR_PHOTO" :on-remove="handleRemove"
                  :before-upload="handlePreviewINTERIOR_PHOTO" :before-remove="beforeRemove" :data='fileUloadParams'
                  :limit="1" :on-exceed="handleExceed" :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
              <el-form-item v-if="merchantEntry.merchantType == 'PERSON'" label="结算卡正面照片" prop="BANK_CARD">
                <el-upload class="upload-demo"
                  action="http://service.gdsmr.cn:8765/merchantOrigin.controller/MerchantOrigin/uploadOrigin"
                  :on-preview="handlePreviewBANK_CARD" :on-remove="handleRemove" :before-upload="handlePreviewBANK_CARD"
                  :before-remove="beforeRemove" :data='fileUloadParams' :limit="1" :on-exceed="handleExceed"
                  :file-list="fileList">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
              </el-form-item>
            </el-form>

          </div>



          <div v-if="active == 2" class="block">
            <el-table v-loading="listLoading" :data="merchantPaymentList" element-loading-text="Loading" border fit
              highlight-current-row>
              <el-table-column align="center" label="序号" width="95">
                <template slot-scope="scope">
                  {{ scope.$index }}
                </template>
              </el-table-column>

              <el-table-column label="主键" width="110">
                <template slot-scope="scope">
                  {{ scope.row.id }}
                </template>
              </el-table-column>
              <el-table-column label="商户编号" width="110">
                <template slot-scope="scope">
                  {{ scope.row.merchantId }}
                </template>
              </el-table-column>
              <el-table-column label="组织编号" width="110">
                <template slot-scope="scope">
                  {{ scope.row.organId }}
                </template>
              </el-table-column>
              <el-table-column label="组织路径" width="110">
                <template slot-scope="scope">
                  {{ scope.row.organPath }}
                </template>
              </el-table-column>
              <el-table-column label="支付类型" width="110">
                <template slot-scope="scope">
                  {{ scope.row.paymentType }}
                </template>
              </el-table-column>
              <el-table-column label="产品类型" width="110">
                <template slot-scope="scope">
                  {{ scope.row.productType }}
                </template>
              </el-table-column>
              <el-table-column label="删除标识" width="110">
                <template slot-scope="scope">
                  {{ scope.row.isDeleted }}
                </template>
              </el-table-column>
              <el-table-column label="费率百分比" width="110">
                <template slot-scope="scope">
                  {{ scope.row.feeValueRate }}
                </template>
              </el-table-column>
              <el-table-column label="最小收费金额" width="110">
                <template slot-scope="scope">
                  {{ scope.row.minFee }}
                </template>
              </el-table-column>
              <el-table-column label="客户端类型" width="110">
                <template slot-scope="scope">
                  {{ scope.row.clientType }}
                </template>
              </el-table-column>
              <el-table-column label="开通成功" width="110">
                <template slot-scope="scope">
                  {{ scope.row.applySuccess }}
                </template>
              </el-table-column>
              <el-table-column label="备注" width="110">
                <template slot-scope="scope">
                  {{ scope.row.remark }}
                </template>
              </el-table-column>


              <el-table-column align="center" prop="created_at" label="操作" width="200">
                <template slot-scope="scope">
                  <span class="el-tag el-tag--info el-tag--mini" style="cursor: pointer;"
                    @click="handleEdit(scope.$index, scope.row)">
                    {{ scope.row.isSet ? '保存' : "修改" }}
                  </span>
                  <span v-if="!scope.row.isSet" class="el-tag el-tag--danger el-tag--mini" style="cursor: pointer;"
                    @click="handleDelete(scope.$index, scope.row)">
                    删除
                  </span>
                </template>
              </el-table-column>
            </el-table>
          </div>


          <div v-if="active == 3">

            <el-form :model="form" :inline="true" :label-position="labelPosition" label-width="110px">

              <el-form-item label="合利宝平台商编">
                <el-input v-model="merchantHelipayWechat.firstClassMerchantNo" placeholder="合利宝平台商编"
                  auto-complete="off" />
              </el-form-item>

              <el-form-item label="所属合利宝商户">
                <el-input v-model="merchantHelipayWechat.merchantNo" placeholder="所属合利宝商户" auto-complete="off" />
              </el-form-item>

              <el-form-item label="订阅公众号">
                <el-input v-model="merchantHelipayWechat.subscribeAppidsPub" placeholder="订阅公众号" auto-complete="off" />
              </el-form-item>

              <el-form-item label="订阅小程序号">
                <el-input v-model="merchantHelipayWechat.subscribeAppidsApplet" placeholder="订阅小程序号"
                  auto-complete="off" />
              </el-form-item>

              <el-form-item label="支付公众号">
                <el-input v-model="merchantHelipayWechat.payAppidsPub" placeholder="支付公众号" auto-complete="off" />
              </el-form-item>

              <el-form-item label="支付授权目录列表">
                <el-input v-model="merchantHelipayWechat.authFold" placeholder="支付授权目录列表" auto-complete="off" />
              </el-form-item>

              <el-form-item label="渠道名">
                <el-input v-model="merchantHelipayWechat.merchantChannelName" placeholder="渠道名" auto-complete="off" />
              </el-form-item>

              <el-form-item label="报备类型">
                <el-select v-model="merchantHelipayWechat.applyType" placeholder="报备类型">
                  <el-option v-for="item in query.appApplyTypeOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>

              <el-form-item label="操作类型">

                <el-select v-model="merchantHelipayWechat.operateType" placeholder="操作类型">
                  <el-option v-for="item in query.wechatOperateTypeOptions" :key="item.value" :label="item.label"
                    :value="item.value" />
                </el-select>
              </el-form-item>

              <el-form-item label="备注">
                <el-input v-model="merchantHelipayWechat.remark" placeholder="备注" auto-complete="off" />
              </el-form-item>
            </el-form>
          </div>

          <div v-if="active == 4">

            <div class="Search">
              <!--工具条-->
              <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
                <el-form :inline="true" :model="query">


                  <el-form-item>

                    <el-select v-model="query.merchantHelipayApp.appPayType" clearable placeholder="客户端类型">
                      <el-option v-for="item in query.appAppPayTypeOptions" :key="item.value" :label="item.label"
                        :value="item.value" />
                    </el-select>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="handleQueryAppReport">查询</el-button>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="success" @click="handleAddAppReport">添加APP待报备信息</el-button>
                  </el-form-item>
                </el-form>
              </el-col>
            </div>

            <el-table v-loading="listLoading" :data="merchantHelipayApplist" element-loading-text="Loading" border fit
              highlight-current-row>
              <el-table-column align="center" label="序号" width="95">
                <template slot-scope="scope">
                  {{ scope.$index }}
                </template>
              </el-table-column>
              <el-table-column label="合利宝平台商编" width="110">
                <template slot-scope="scope">
                  {{ scope.row.firstClassMerchantNo }}
                </template>
              </el-table-column>

              <el-table-column label="所属组织名称" width="110">
                <template slot-scope="scope">
                  {{ scope.row.organName }}
                </template>
              </el-table-column>

              <el-table-column label="所属合利宝商户" width="110">
                <template slot-scope="scope">
                  {{ scope.row.merchantNo }}
                </template>
              </el-table-column>
              <el-table-column label="客户端类型" width="110">
                <template slot-scope="scope">
                  {{ scope.row.appPayType }}
                </template>
              </el-table-column>
              <el-table-column label="报备类型" width="110">
                <template slot-scope="scope">
                  {{ scope.row.applyType }}
                </template>
              </el-table-column>
              <el-table-column label="报备成功标识" width="110">
                <template slot-scope="scope">
                  {{ scope.row.applySuccess }}
                </template>
              </el-table-column>
              <el-table-column label="备注" width="110">
                <template slot-scope="scope">
                  {{ scope.row.remark }}
                </template>
              </el-table-column>

              <el-table-column align="center" label="操作" width="200">
                <template slot-scope="scope">
                  <span class="el-tag el-tag--info el-tag--mini" style="cursor: pointer;"
                    @click="handleEdit(scope.$index, scope.row)">
                    {{ scope.row.isSet ? '保存' : "修改" }}
                  </span>
                  <span v-if="!scope.row.isSet" class="el-tag el-tag--danger el-tag--mini" style="cursor: pointer;"
                    @click="handleDelete(scope.$index, scope.row)">
                    删除
                  </span>
                </template>
              </el-table-column>
            </el-table>
            <div class="block">
              <el-pagination :current-page="query.merchantHelipayApp.currentPage" :page-sizes="[10, 20, 30, 40]"
                :page-size="query.merchantHelipayApp.pageSize" layout="total, sizes, prev, pager, next, jumper"
                :total="query.merchantHelipayApp.total" @size-change="handleSizeChangeApp"
                @current-change="handleCurrentChangeApp" />
            </div>

          </div>

          <div slot="footer" class="dialog-footer">
            <el-button v-if="active != 0" type="primary" @click="handleLastStep">上一步</el-button>
            <el-button v-if="active == 4" @click="dialogFormMerchantRegisterVisible = false">取 消</el-button>
            <el-button v-if="active == 4" type="primary" @click="handleMerchantRegisterSave('merchantEntryForm')">确
              定</el-button>
            <el-button v-if="active != 4" type="primary" @click="handleNextStep">下一步</el-button>
          </div>
        </el-dialog>
      </div>


      <div class="block">
        <!--弹框-->
        <el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogMerchantHelipayAppFormVisible">

          <el-form :model="form" :inline="true" :label-position="labelPosition" label-width="110px">
            <el-form-item label="合利宝平台商编">
              <el-input v-model="merchantHelipayApp.firstClassMerchantNo" placeholder="合利宝平台商编" auto-complete="off" />
            </el-form-item>
            <el-form-item label="所属合利宝商户">
              <el-input v-model="merchantHelipayApp.merchantNo" placeholder="所属合利宝商户" auto-complete="off" />
            </el-form-item>

            <el-form-item label="客户端类型">
              <el-select v-model="merchantHelipayApp.appPayType" placeholder="客户端类型">
                <el-option v-for="item in query.appAppPayTypeOptions" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>

            <el-form-item label="报备类型">
              <el-select v-model="merchantHelipayApp.applyType" placeholder="报备类型">
                <el-option v-for="item in query.appApplyTypeOptions" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>

            <el-form-item label="备注">
              <el-input v-model="merchantHelipayApp.remark" placeholder="备注" auto-complete="off" />
            </el-form-item>

          </el-form>

          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogMerchantHelipayAppFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="handleMerchantHelipayAppSave">确 定</el-button>
          </div>

        </el-dialog>
      </div>
    </div>
  </div>
</template>
<script>
import { getList, doDelete, doEdit, getUserList, doEntrySubmit, doUploadCredential, doSetupProduct, doWechatApply, doAppApply } from '@/api/Merchant/'
import { doEdit as doMerchantEntryRegister, doQueryCount as doQueryMerchantEntryCount, doQueryList as doQueryMerchantEntryList } from '@/api/MerchantEntry/'
import { doQueryHelipayConf } from '@/api/MerchantHelipay/'
import { getList as doQueryHelipayAppList, doEdit as doEditHelipayApp } from '@/api/MerchantHelipayApp/'
import { doQueryWechat as doQueryHelipayWechat, doEdit as doEditHelipayWechat } from '@/api/MerchantHelipayWechat/'
import { doQueryOrigins as doQueryMerchantOrigins } from '@/api/MerchantOrigin/'
import { doQueryPayments as doQueryMerchantPayments, doInitPayments as doInitMerchantPayments } from '@/api/MerchantPayment/'

import { getDictionaryGroup } from '@/api/dictionary'
import { getOrganId, getTenantId, getOrganPath, getCurrentLoginUserId, handleBuildTreeDataStruct, getSuperManagerId, getSelectedNodes, getSelectedNodesObject, getSystemErrorCode } from '@/api/utils'
import { getTenantList, getToken, getOrganList, getDictionary, translateOrganId2OrganName } from '@/utils/auth'
import localStorageUtil from '@/utils/localStorageUtil'
import sessionStorageUtil from '@/utils/sessionStorageUtil'

export default {
  data() {
    return {
      regform: {
        id: '',
        name: '',
        type: '',
        organId: '',
        organPath: '',
        isMain: '',
        cooperationMode: '',
        userId: '',
        ifCheckUser: true,
        ifCheckIsMain: true,
        profitSharingRate: '',
        'id': ''
      },
      dialogFormVisibleReg: false,
      list: null,
      merchantHelipayApplist: null,
      merchantPaymentList: null,
      listLoading: true,
      total: 5,
      currentPage: 1,
      pageSize: 10,
      dialogFormVisible: false,
      dialogFormMerchantRegisterVisible: false,
      dialogMerchantHelipayAppFormVisible: false,
      addForVisible: false,
      labelPosition: 'right',
      props: { // 配置项（必选）
        value: 'id',
        label: 'userName',
        children: 'children',
        title: '用户'
        // disabled:true
      },
      isClearable: true, // 可清空（可选）
      isAccordion: true, // 可收起（可选）
      userValueId: {}, // 初始ID（可选）
      userOptionData: [],
      oldUserId: '',
      oldIsMain: '',
      form: {
        id: '',
        name: '',
        type: '',
        organId: '',
        organPath: '',
        isMain: '',
        cooperationMode: '',
        userId: '',
        ifCheckUser: true,
        ifCheckIsMain: true,
        profitSharingRate: ''
      },
      active: 0,
      nonePersonal: false,
      fileUloadParams: { organId: 1, merchantId: 1 },
      fileList: [],
      merchantHelipayApp: {
        id: '',
        firstClassMerchantNo: '',
        merchantNo: '',
        organId: '',
        organPath: '',
        organName: '',
        organParentId: '',
        merchantId: '',
        merchantNo: '',
        appPayType: '',
        applyType: '',
        applySuccess: '',
        isReferenceToParent: '',
        isDeleted: '',
        createBy: '',
        createDate: '',
        updateBy: '',
        updateDate: '',
        remark: ''
      },
      merchantEntry: {
        id: '',
        firstClassMerchantNo: '',
        orderId: '',
        signName: '',
        merchantType: '',
        merchantNo: '',
        merchantCategory: '',
        showName: '',
        webSite: '',
        accessUrl: '',
        legalPerson: '',
        legalPersonId: '',
        orgNum: '',
        businessLicense: '',
        regionCode: '',
        industryTypeCode: '',
        address: '',
        linkMan: '',
        linkPhone: '',
        email: '',
        bindMobile: '',
        bankCode: '',
        accountName: '',
        accountNo: '',
        settleBankType: '',
        settlementPeriod: '',
        settlementMode: '',
        settleMode: '',
        authorizationFlag: '',
        servicePhone: '',
        unionPayQrCode: '',
        needPosFunction: '',
        idCardStartDate: '',
        idCardEndDate: '',
        businessDateStart: '',
        businessDateLimit: '',
        accountIdCard: '',
        isDeleted: '',
        mcc: '',
        agreeProtocol: '',
        callbackUrl: '',
        settlementIdCardStartDate: '',
        settlementIdCardEndDate: '',
        settlementIdCardNo: '',
        settlementAuth: '',
        createBy: '',
        updateBy: '',
        createDate: '',
        updateDate: '',
        remark: ''
      },
      merchantHelipay: {
        id: '',
        firstClassMerchantNo: '',
        organId: '',
        organPath: '',
        organName: '',
        organParentId: '',
        merchantId: '',
        tradeSignKey: '',
        tradeEncodeKey: '',
        settlementSignKey: '',
        settlementEncodeKey: '',
        scanSignKey: '',
        scanEncodeKey: '',
        publicSignKey: '',
        publicEncodeKey: '',
        payCenterSignKey: '',
        payCenterEncodeKey: '',
        isReferenceToParent: '',
        isDeleted: '',
        feeValueRate: '',
        minFee: '',
        createBy: '',
        createDate: '',
        updateBy: '',
        updateDate: '',
        remark: ''
      },
      merchantHelipayWechat: {
        id: '',
        firstClassMerchantNo: '',
        merchantNo: '',
        organId: '',
        organPath: '',
        organName: '',
        organParentId: '',
        merchantId: '',
        merchantNo: '',
        subscribeAppidsPub: '',
        subscribeAppidsApplet: '',
        payAppidsPub: '',
        merchantChannelName: '',
        isReferenceToParent: '',
        applyType: '',
        operateType: '',
        isDeleted: '',
        applySuccess: '',
        authFold: '',
        createBy: '',
        createDate: '',
        updateBy: '',
        updateDate: '',
        remark: ''
      },
      merchantOrigin: {
        FRONT_OF_ID_CARD: '',
        BACK_OF_ID_CARD: '',
        TAX_REG_CERTIFICATE: '',
        ORG_CERTIFICATE: '',
        PERMIT_FOR_BANK_ACCOUNT: '',
        BUSINESS_LICENSE: '',
        SIGN_BOARD: '',
        CHECKOUT_COUNTER: '',
        INTERIOR_PHOTO: '',
        BANK_CARD: ''
      },
      merchantHelipayWechatRules: {
        firstClassMerchantNo: [{ required: true, message: '请输入商户名称', trigger: 'blur' }],
        merchantNo: [{ required: true, message: '请选择商户类型', trigger: 'blur' }],
        subscribeAppidsPub: [{ required: true, message: '请选择是否为主商户', trigger: 'blur' }],
        subscribeAppidsApplet: [{ required: true, message: '请输入默认分润比例', trigger: 'blur' }],
        payAppidsPub: [{ required: true, message: '请选择合伙方式', trigger: 'blur' }]
      },
      merchantRules: {
        name: [{ required: true, message: '请输入商户名称', trigger: 'blur' }],
        type: [{ required: true, message: '请选择商户类型', trigger: 'blur' }],
        isMain: [{ required: true, message: '请选择是否为主商户', trigger: 'blur' }],
        profitSharingRate: [{ required: true, message: '请输入默认分润比例', trigger: 'blur' }],
        cooperationMode: [{ required: true, message: '请选择合伙方式', trigger: 'blur' }]
      },
      merchantEntryRules: {
        firstClassMerchantNo: [{ required: true, message: '请输入平台编户编号', trigger: 'blur' }],
        signName: [{ required: true, message: '请输入子商户签约名', trigger: 'blur' }],
        merchantType: [{ required: true, message: '请选择商户类型', trigger: 'blur' }],
        merchantCategory: [{ required: true, message: '请选择经营类别', trigger: 'blur' }],
        showName: [{ required: true, message: '请输入展示名（收银台展示）', trigger: 'blur' }],
        webSite: [{ required: true, message: '请输入网站网址', trigger: 'blur' }],
        accessUrl: [{ required: true, message: '请输入接入地址', trigger: 'blur' }],
        legalPerson: [{ required: true, message: '请输入法人名字', trigger: 'blur' }],
        legalPersonId: [{ required: true, message: '请输入法人身份证号', trigger: 'blur' }],
        orgNum: [{ required: true, message: '请输入组织机构代码', trigger: 'blur' }],
        businessLicense: [{ required: true, message: '请输入营业执照号', trigger: 'blur' }],
        regionCode: [{ required: true, message: '请输入区域编码', trigger: 'blur' }],
        industryTypeCode: [{ required: true, message: '请输入行业类型编码', trigger: 'blur' }],
        address: [{ required: true, message: '请输入通讯地址', trigger: 'blur' }],
        linkMan: [{ required: true, message: '请输入联系人姓名', trigger: 'blur' }],
        linkPhone: [{ required: true, message: '请输入联系人手机号', trigger: 'blur' }],
        email: [{ required: true, message: '请输入联系邮箱', trigger: 'blur' }],
        bindMobile: [{ required: true, message: '请输入绑定手机', trigger: 'blur' }],
        bankCode: [{ required: true, message: '请输入结算卡联行号（需要致电银行卡支行咨询）', trigger: 'blur' }],
        accountName: [{ required: true, message: '请输入银行开户名', trigger: 'blur' }],
        accountNo: [{ required: true, message: '请输入银行开户账号', trigger: 'blur' }],
        settleBankType: [{ required: true, message: '请选择结算卡类型', trigger: 'blur' }],
        settlementPeriod: [{ required: true, message: '请选择结算周期', trigger: 'blur' }],
        settlementMode: [{ required: true, message: '请选择结算方式', trigger: 'blur' }],
        settleMode: [{ required: true, message: '请选择结算模式', trigger: 'blur' }],
        authorizationFlag: [{ required: true, message: '请选择授权使用大商户秘钥', trigger: 'blur' }],
        servicePhone: [{ required: true, message: '请输入客服联系电话', trigger: 'blur' }],
        unionPayQrCode: [{ required: true, message: '请输入银联二维码', trigger: 'blur' }],
        needPosFunction: [{ required: true, message: '请选择是否需要开通POS功能（平台商需开通）', trigger: 'blur' }],
        idCardStartDate: [{ required: true, message: '请输入法人身份证开始日期', trigger: 'blur' }],
        idCardEndDate: [{ required: true, message: '请输入法人身份证结束日期', trigger: 'blur' }],
        businessDateStart: [{ required: true, message: '请输入经营起始日期', trigger: 'blur' }],
        businessDateLimit: [{ required: true, message: '请输入经营期限', trigger: 'blur' }],
        accountIdCard: [{ required: true, message: '请输入开户人身份证号', trigger: 'blur' }],
        mcc: [{ required: true, message: '请输入mcc', trigger: 'blur' }],
        agreeProtocol: [{ required: true, message: '请选择是否同意协议', trigger: 'blur' }],
        callbackUrl: [{ required: true, message: '请输入回调地址', trigger: 'blur' }],
        settlementIdCardStartDate: [{ required: true, message: '请输入结算人身份证开始日期', trigger: 'blur' }],
        settlementIdCardEndDate: [{ required: true, message: '请输入结算人身份证结束日期', trigger: 'blur' }],
        settlementAuth: [{ required: true, message: '请输入结算信息鉴权', trigger: 'blur' }],
        settlementIdCardNo: [{ required: true, message: '请输入结算人身份证号', trigger: 'blur' }]
      },
      merchantOriginRules: {
        FRONT_OF_ID_CARD: [{ required: true, message: '请上传身份证正面', trigger: 'blur' }],
        BACK_OF_ID_CARD: [{ required: true, message: '请上传身份证反面', trigger: 'blur' }],
        isMain: [{ required: true, message: '请选择是否为主商户', trigger: 'blur' }],
        profitSharingRate: [{ required: true, message: '请输入默认分润比例', trigger: 'blur' }],
        cooperationMode: [{ required: true, message: '请选择合伙方式', trigger: 'blur' }]
      },
      // 新增or编辑弹框标题(根据点击的新增or编辑按钮显示不同的标题)
      titleMap: {
        add: '新增',
        edit: '编辑',
        merchantRegister: '商户支付开通',
        applyType: '应用报备'
      },
      // 新增和编辑弹框标题
      dialogStatus: '',
      firstClassMerchantNo: '',
      merchantNo: '',
      query: {
        merchantHelipayApp: {
          appAppPayType: '',
          total: 5,
          currentPage: 1,
          pageSize: 10,
        },
        params: {
          id: '', //商户名称
          name: '', //商户名称
          type: '', //商户类型,1 企业商户，2, 个体商户， 3 个人商户
          organId: '', //
          organPath: '', //
          isMain: '', //是否主商户，0 为从商户，1为主商户
          total: 5,
          currentPage: 1,
          pageSize: 10
        },
        timeValue: '',
        merchantTypeOptions: [],
        isMainOptions: [],
        cooperationModeOptions: [],
        settlementAuthOptions: [],
        settleBankTypeOptions: [],
        settleModeOptions: [],
        settlementPeriodOptions: [],
        merchantCategoryOptions: [],
        settlementModeOptions: [],
        merchantTypeOptions: [],
        authorizationFlagOptions: [],
        needPosFunctionOptions: [],
        appAppPayTypeOptions: [],
        appApplyTypeOptions: [],
        wechatOperateTypeOptions: [],
        paymentTypeOptions: [],
        productTypeOptions: [],
        value: ''
      }
    }
  },
  created() {

    this.handleInitSettlementAuth()
    this.handleInitSettleBankType()
    this.handleInitMerchantCategory()
    this.handleInitSettlementPeriod()
    this.handleInitSettleMode()
    this.handleInitSettlementMode()
    this.handleInitSettleMode()
    this.handleInitMerchantType()
    this.handleBuildMerchantTypeOptions();
    this.handleInitMerchantEntryAuthorizationFlag()
    this.handleBuildIsMainOptions()
    this.handleBuildCooperationModeOptions()
    this.handleInitMerchantEntryNeedPosFunction()
    this.handleInitMerchantHelipayAppAppPayType()
    this.handleInitMerchantHelipayAppApplyType()
    this.handleInitMerchantHelipayWechatOperateType()
    this.handleInitMerchantPaymentPaymentType()
    this.handleInitMerchantPaymentPaymentType()
    this.initUserTree();
    this.fetchData();
  },
  methods: {
    doMerchantReg(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          doEdit(this.form).then(response => {
            const data = response.data
            if (data.successful) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
              this.fetchData();
              this.dialogFormVisibleReg = false
            } else {
              this.$message({
                type: 'warning',
                message: data.description
              })
            }
            this.listLoading = false
          })
        } else {
          console.log('error submit!!');
          return false;
        }

      })

    },
    toMerchantReg(index, row) {

      this.dialogFormVisibleReg = true;

    },
    getUserValue(value) {
      this.form.userId = value.id; //用户id
    },
    initUserTree() {
      this.listLoading = true
      getUserList({ organPath: getOrganPath() }).then(response => {
        console.log(response)
        const data = response.data.entities
        this.userOptionData = handleBuildTreeDataStruct(data, 'id', 'parentId')
        this.listLoading = false
      })
    },
    handleBuildCooperationModeOptions() {
      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "cooperationMode" && item.parentId != '0';
      })
      let cooperationModeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        cooperationModeOptions.push(option)
      }
      this.query.cooperationModeOptions = cooperationModeOptions
    },
    cooperationMode(row, column) {
      let label = ''
      for (let i = 0; i < this.query.cooperationModeOptions.length; i++) {
        if ('' + row.cooperationMode === this.query.cooperationModeOptions[i].value) {
          return this.query.cooperationModeOptions[i].label
        }

      }
      return label

    },
    handleBuildIsMainOptions() {
      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "isMain" && item.parentId != '0';
      })
      let isMainOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        isMainOptions.push(option)
      }
      this.query.isMainOptions = isMainOptions

    },
    isMain(row, column) {
      let label = ''
      for (let i = 0; i < this.query.isMainOptions.length; i++) {
        if ('' + row.isMain === this.query.isMainOptions[i].value) {
          return this.query.isMainOptions[i].label
        }

      }
      return label
    },
    handleBuildMerchantTypeOptions() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantType" && item.parentId != '0';
      })
      let merchantTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        merchantTypeOptions.push(option)
      }
      this.query.merchantTypeOptions = merchantTypeOptions
      console.log(this.query.merchantTypeOptions);
    },
    merchantType(row, column) {
      let label = ''
      for (let i = 0; i < this.query.merchantTypeOptions.length; i++) {
        if ('' + row.type === this.query.merchantTypeOptions[i].value) {
          return this.query.merchantTypeOptions[i].label
        }
      }
      return label
    },
    fetchData() {
      this.createOrganQuery()
      this.currentPage = this.currentPage || 1
      this.pageSize = this.pageSize || 10
      this.listLoading = true
      getList(this.query.params, this.currentPage, this.pageSize).then(response => {
        const data = response.data
        if (!data.entities || typeof data.successful != 'undefined') {
          this.$message({
            type: 'info',
            message: data.description || getSystemErrorCode(data.status)
          })
          return;
        }
        this.total = data.totalCount
        this.pageSize = data.pageSize
        this.currentPage = data.currentPage
        this.list = data.entities
        this.listLoading = false
      })
    },
    createOrganQuery() {
      // 选中了租户
      let tenantSelected = this.$refs['tenantTree'] && this.$refs['tenantTree'].getCheckedNodes() || []
      let organSelected = this.$refs['organTree'] && this.$refs['organTree'].getCheckedNodes() || []
      let that = this
      this.query.params.organId = null
      if (tenantSelected.length && tenantSelected[0]) {
        this.query.params.tenantId = tenantSelected[0].data.id
        if (organSelected.length && organSelected[0]) {
          if (this.props.multiple) {
            this.query.params.organId = null
            this.query.params.organIds = []
            if (organSelected.length && organSelected[0]) {
              organSelected.forEach(function (element) {
                that.query.params.organIds.push(element.data.id)
              })
            }
          } else if (organSelected.length && organSelected[0]) {
            this.query.params.organPath = organSelected[0] && organSelected[0].data.organPath
          }
        }
      } else {
        this.query.params.tenantId = getTenantId()
        if (organSelected.length && organSelected[0]) {
          if (this.props.multiple) {
            this.query.params.organId = null
            this.query.params.organIds = []
            if (organSelected.length && organSelected[0]) {
              organSelected.forEach(function (element) {
                that.query.params.organIds.push(element.data.id)
              })
            }
          } else if (organSelected.length && organSelected[0]) {
            this.query.params.organPath = organSelected[0].data.organPath
          }
        }
      }
      this.query.params.organId = this.query.params.organId || getOrganId()
      this.query.params.organPath = this.query.params.organPath || getOrganPath()
    },
    handleSizeChange(val) {
      this.currentPage = 1
      this.pageSize = val
      this.fetchData();
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.fetchData();
    },
    // 新增
    handleAdd() {
      // 显示弹框
      this.dialogFormVisible = true
      // 新增弹框标题
      this.dialogStatus = 'add'

      this.form.id = ''
      this.form.name = ''
      this.form.type = ''
      this.form.organId = getOrganId();
      this.form.organPath = getOrganPath();
      this.form.isMain = ''
      this.form.profitSharingRate = '';
      this.form.cooperationMode = ''
      this.form.ifCheckUser = true;
      this.form.ifCheckIsMain = true;
      /* this.$refs.UserSelectTree.value();
       console.log( this.$refs.UserSelectTree.name);*/
      this.addForVisible = false
    },
    // 编辑
    handleEdit(index, row) {
      console.log(index)
      console.log(row)
      this.form.id = row.id
      this.form.name = row.name
      this.form.type = '' + row.type
      this.form.isMain = '' + row.isMain
      this.form.profitSharingRate = row.profitSharingRate;
      this.oldIsMain = '' + row.isMain;
      this.form.cooperationMode = '' + row.cooperationMode
      this.userValueId = row.userId
      this.form.userId = row.userId
      this.oldUserId = row.userId;


      this.addForVisible = true
      // 显示弹框
      this.dialogFormVisible = true
      // 编辑弹框标题
      this.dialogStatus = 'edit'
    },
    handleDelete(index, row) {
      console.log(index)
      console.log(row)

      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        doDelete(row.id).then(response => {
          const data = response.data
          console.log(data)
          if (data.status == 1) {
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
            this.fetchData();
          } else if (data.status == 403) {
            this.$message({
              type: 'warning',
              message: data.description
            })
          } else {
            this.$message({
              type: 'info',
              message: '操作失败!'
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    handleEditSave(formName) {


      if (this.form.userId === this.oldUserId) {
        this.form.ifCheckUser = false;
      } else {
        this.form.ifCheckUser = true;
      }
      if (this.form.isMain === this.oldIsMain) {
        this.form.ifCheckIsMain = false;
      } else {
        this.form.ifCheckIsMain = true;
      }
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.form.userId == null || this.form.userId == '') {
            this.$message({
              type: 'warning',
              message: `请选择绑定用户!`
            })
            return;
          }

          doEdit(this.form).then(response => {
            console.log(response)
            const data = response.data
            if (data.status) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
              this.fetchData();
              this.dialogFormVisible = false
            } else {
              this.$message({
                type: 'warning',
                message: data.description
              })
            }
            this.listLoading = false
          })
        } else {
          console.log('error submit!!');
          return false;
        }

      })
    },
    handleYYYY_MM_dd2YYYYMMdd(origin) {

      if (origin) {
        return origin.replace(/-/g, "")
      }
      return null;
    },
    handleMerchantRegisterSave(formName) {//商户银行卡收款账户注册添加

      this.$refs[formName].validate((valid) => {

        if (valid) {
          this.active++;
          this.listLoading = true

          this.merchantEntry.idCardStartDate = this.handleYYYY_MM_dd2YYYYMMdd(this.merchantEntry.idCardStartDate)
          this.merchantEntry.idCardEndDate = this.handleYYYY_MM_dd2YYYYMMdd(this.merchantEntry.idCardEndDate)
          this.merchantEntry.businessDateStart = this.handleYYYY_MM_dd2YYYYMMdd(this.merchantEntry.businessDateStart)
          this.merchantEntry.businessDateLimit = this.handleYYYY_MM_dd2YYYYMMdd(this.merchantEntry.businessDateLimit)
          this.merchantEntry.settlementIdCardStartDate = this.handleYYYY_MM_dd2YYYYMMdd(this.merchantEntry.settlementIdCardStartDate)
          this.merchantEntry.settlementIdCardEndDate = this.handleYYYY_MM_dd2YYYYMMdd(this.merchantEntry.settlementIdCardEndDate)

          doMerchantEntryRegister(this.merchantEntry).then(response => {
            debugger
            console.log(response)
            const data = response.data
            if (data.status) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
              //查询或初始化商户支付
              this.handleQueryAndInitMerchantPayment()

            } else {

              this.$message({
                type: 'info',
                message: '操作失败!'
              })

            }
            this.listLoading = false
            this.dialogFormVisible = false
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    handleReset() {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 新增
    handleMerchantRegister(index, row) {
      this.active = 0
      //查询是否已经开通银行卡收款账户
      doQueryMerchantEntryList({}, getOrganId(), row.id).then(response => {
        debugger
        const data = response.data
        if (data.length && data[0].applySuccess) {

          this.merchantEntry = data[0]
          this.$confirm('此商户已经开通银行卡收款账户, 是否还要重新开通?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            center: true
          }).then(() => {
            //新的收款账户开通
            //this.handleNewMerchantEntry(row)
            this.$message({
              type: 'warning',
              message: '操作暂不支持!'
            })

          }).catch(() => {

            this.$message({
              type: 'info',
              message: '操作已取消!'
            })

            //TODO 

          })
        } else if (data.length && !data[0].applySuccess) {
          //进件资料已填写，但还未提交到第三方,或者第三方拒绝
          this.merchantEntry = data[0]
          this.dialogFormMerchantRegisterVisible = true
          this.firstClassMerchantNo = data[0].firstClassMerchantNo
          this.merchantNo = data[0].merchantNo
          // 新增弹框标题
          this.dialogStatus = 'merchantRegister'
          this.form.id = row.id

          //查询或初始化商户支付
          //this.handleQueryAndInitMerchantPayment()

        } else {

          doQueryHelipayConf({}, getOrganId(), row.id).then(response => {

            const data = response.data
            if (data.data) {
              this.merchantEntry.firstClassMerchantNo = data.data.firstClassMerchantNo
              this.merchantHelipay = data.data

            }
            this.firstClassMerchantNo = this.merchantEntry.firstClassMerchantNo
            //新的收款账户开通
            this.handleNewMerchantEntry(row, data.data.firstClassMerchantNo);
            //查询或初始化商户支付
            //this.handleQueryAndInitMerchantPayment()
          })

        }
      })

    },
    handleNewMerchantEntry(row, firstClassMerchantNo) {
      // 显示弹框
      this.dialogFormMerchantRegisterVisible = true
      // 新增弹框标题
      this.dialogStatus = 'merchantRegister'
      this.form.id = row.id
      this.merchantEntry.id = ''
      this.merchantEntry.organId = getOrganId()
      this.merchantEntry.merchantId = row.id
      this.merchantEntry.firstClassMerchantNo = firstClassMerchantNo
      this.merchantEntry.orderId = ''
      this.merchantEntry.signName = ''
      this.merchantEntry.merchantType = ''
      this.merchantEntry.merchantCategory = ''
      this.merchantEntry.showName = ''
      this.merchantEntry.webSite = ''
      this.merchantEntry.accessUrl = ''
      this.merchantEntry.legalPerson = ''
      this.merchantEntry.legalPersonId = ''
      this.merchantEntry.orgNum = ''
      this.merchantEntry.businessLicense = ''
      this.merchantEntry.regionCode = ''
      this.merchantEntry.industryTypeCode = ''
      this.merchantEntry.address = ''
      this.merchantEntry.linkMan = ''
      this.merchantEntry.linkPhone = ''
      this.merchantEntry.email = ''
      this.merchantEntry.bindMobile = ''
      this.merchantEntry.bankCode = ''
      this.merchantEntry.accountName = ''
      this.merchantEntry.accountNo = ''
      this.merchantEntry.settleBankType = ''
      this.merchantEntry.settlementPeriod = ''
      this.merchantEntry.settlementMode = ''
      this.merchantEntry.settleMode = ''
      this.merchantEntry.authorizationFlag = ''
      this.merchantEntry.servicePhone = ''
      this.merchantEntry.unionPayQrCode = ''
      this.merchantEntry.needPosFunction = ''
      this.merchantEntry.idCardStartDate = ''
      this.merchantEntry.idCardEndDate = ''
      this.merchantEntry.businessDateStart = ''
      this.merchantEntry.businessDateLimit = ''
      this.merchantEntry.accountIdCard = ''
      this.merchantEntry.isDeleted = ''
      this.merchantEntry.mcc = ''
      this.merchantEntry.agreeProtocol = ''
      this.merchantEntry.callbackUrl = ''
      this.merchantEntry.settlementIdCardStartDate = ''
      this.merchantEntry.settlementIdCardEndDate = ''
      this.merchantEntry.settlementIdCardNo = ''
      this.merchantEntry.settlementAuth = ''
      this.merchantEntry.createBy = ''
      this.merchantEntry.updateBy = ''
      this.merchantEntry.createDate = ''
      this.merchantEntry.updateDate = ''
      this.merchantEntry.remark = ''
      this.addForVisible = false
    },
    handleInitSettlementAuth() {


      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntrySettlementAuth" && item.parentId != '0';
      })
      let settlementAuthOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        settlementAuthOptions.push(option)
      }
      this.query.settlementAuthOptions = settlementAuthOptions

    },
    handleInitSettleBankType() {


      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntrySettleBankType" && item.parentId != '0';
      })

      let settleBankTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        settleBankTypeOptions.push(option)
      }
      this.query.settleBankTypeOptions = settleBankTypeOptions
    },

    handleInitSettleMode() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntrySettleBankType" && item.parentId != '0';
      })

      let settleModeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        settleModeOptions.push(option)
      }
      this.query.settleModeOptions = settleModeOptions

    },
    handleInitSettlementPeriod() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntrySettlementPeriod" && item.parentId != '0';
      })

      let settlementPeriodOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        settlementPeriodOptions.push(option)
      }
      this.query.settlementPeriodOptions = settlementPeriodOptions

    },
    handleInitMerchantCategory() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntryMerchantCategory" && item.parentId != '0';
      })
      let merchantCategoryOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        merchantCategoryOptions.push(option)
      }
      this.query.merchantCategoryOptions = merchantCategoryOptions
    },
    handleInitSettlementMode() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntrySettlementMode" && item.parentId != '0';
      })

      let settlementModeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        settlementModeOptions.push(option)
      }
      this.query.settlementModeOptions = settlementModeOptions
    },
    handleInitMerchantType() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantType" && item.parentId != '0';
      })
      let merchantTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        merchantTypeOptions.push(option)
      }
      this.query.merchantTypeOptions = merchantTypeOptions
    },
    handleInitMerchantEntryAuthorizationFlag() {


      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntryAuthorizationFlag" && item.parentId != '0';
      })

      let authorizationFlagOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        authorizationFlagOptions.push(option)
      }
      this.query.authorizationFlagOptions = authorizationFlagOptions
    },
    handleInitMerchantEntryNeedPosFunction() {


      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantEntryNeedPosFunction" && item.parentId != '0';
      })
      let needPosFunctionOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        needPosFunctionOptions.push(option)
      }
      this.query.needPosFunctionOptions = needPosFunctionOptions
    },
    handleInitMerchantHelipayAppAppPayType() {


      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantHelipayAppAppPayType" && item.parentId != '0';
      })
      let appAppPayTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        appAppPayTypeOptions.push(option)
      }
      this.query.appAppPayTypeOptions = appAppPayTypeOptions
    },
    handleInitMerchantHelipayAppApplyType() {


      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantHelipayAppApplyType" && item.parentId != '0';
      })

      let appApplyTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        appApplyTypeOptions.push(option)
      }
      this.query.appApplyTypeOptions = appApplyTypeOptions
    },
    handleInitMerchantHelipayWechatOperateType() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantHelipayWechatOperateType" && item.parentId != '0';
      })
      let wechatOperateTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        wechatOperateTypeOptions.push(option)
      }
      this.query.wechatOperateTypeOptions = wechatOperateTypeOptions
    },
    handleInitMerchantPaymentPaymentType() {

      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantPaymentPaymentType" && item.parentId != '0';
      })
      let paymentTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        paymentTypeOptions.push(option)
      }
      this.query.paymentTypeOptions = paymentTypeOptions
    },
    handleInitMerchantPaymentPaymentType() {


      const datas = getDictionary()
      let data = datas.filter(function (item, index) {
        return item.bigType === "MerchantPaymentProductType" && item.parentId != '0';
      })
      let productTypeOptions = [];
      for (let i = 0; i < data.length; i++) {

        let option = {}
        option['value'] = data[i].value
        option['label'] = data[i].desc
        productTypeOptions.push(option)
      }
      this.query.productTypeOptions = productTypeOptions
    },
    handleNextStep() {
      debugger

      if (this.active == 3) {

        this.handleEditMerchantHelipayWechat()
      }
      if (this.active == 2) {

        this.handleEditMerchantHelipayWechat()
      }
      if (this.active == 1) {
        this.handleMerchantOriginUpload('merchantOriginForm')

        if (this.merchantEntry.merchantType == 1 || this.merchantEntry.merchantType == 2) {
          this.nonePersonal = true;
        } else {
          this.nonePersonal = false;
        }
        this.handleInitMerchantHelipayWechat()

      }
      if (this.active == 0) {
        this.handleMerchantRegisterSave('merchantEntryForm')
        if (this.merchantEntry.merchantType == 1 || this.merchantEntry.merchantType == 2) {
          this.nonePersonal = true;
        } else {
          this.nonePersonal = false;
        }
        //查询出已经上传的文件
        this.handleQueryMerchantOrigin(getOrganId(), this.form.id)
      }


    },
    handleLastStep() {
      debugger
      this.active--;
      if (this.active == 1) {
        if (this.merchantEntry.merchantType == 1 || this.merchantEntry.merchantType == 2) {
          this.nonePersonal = true;
        } else {
          this.nonePersonal = false;
        }
      }

    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(fileName) {
      this.fileUloadParams.organId = getOrganId()
      this.fileUloadParams.merchantId = this.form.id
      this.fileUloadParams.fileName = fileName
      this.merchantOrigin[fileName] = true
      console.log(fileName);
    },

    handlePreviewFRONT_OF_ID_CARD() {
      debugger
      this.handlePreview('FRONT_OF_ID_CARD')
    },
    handlePreviewBACK_OF_ID_CARD() {
      this.handlePreview('BACK_OF_ID_CARD')
    },
    handlePreviewTAX_REG_CERTIFICATE() {
      this.handlePreview('TAX_REG_CERTIFICATE')
    },
    handlePreviewORG_CERTIFICATE() {
      this.handlePreview('ORG_CERTIFICATE')
    },
    handlePreviewPERMIT_FOR_BANK_ACCOUNT() {
      this.handlePreview('PERMIT_FOR_BANK_ACCOUNT')
    },
    handlePreviewBUSINESS_LICENSE() {
      this.handlePreview('BUSINESS_LICENSE')
    },
    handlePreviewSIGN_BOARD() {
      this.handlePreview('SIGN_BOARD')
    },
    handlePreviewCHECKOUT_COUNTER() {
      this.handlePreview('CHECKOUT_COUNTER')
    },
    handlePreviewINTERIOR_PHOTO() {
      this.handlePreview('INTERIOR_PHOTO')
    },
    handlePreviewBANK_CARD() {
      this.handlePreview('BANK_CARD')
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    handleAddAppReport() {
      this.dialogMerchantHelipayAppFormVisible = true
      this.dialogStatus = 'applyType'
      this.merchantHelipayApp.id = ''
      this.merchantHelipayApp.firstClassMerchantNo = ''
      this.merchantHelipayApp.organId = getOrganId()
      this.merchantHelipayApp.organPath = getOrganPath()
      this.merchantHelipayApp.organName = ''
      this.merchantHelipayApp.organParentId = ''
      this.merchantHelipayApp.merchantId = form.id
      this.merchantHelipayApp.merchantNo = ''
      this.merchantHelipayApp.appPayType = ''
      this.merchantHelipayApp.applyType = ''
      this.merchantHelipayApp.applySuccess = ''
      this.merchantHelipayApp.isReferenceToParent = ''
      this.merchantHelipayApp.isDeleted = ''
      this.merchantHelipayApp.createBy = ''
      this.merchantHelipayApp.createDate = ''
      this.merchantHelipayApp.updateBy = ''
      this.merchantHelipayApp.updateDate = ''
      this.merchantHelipayApp.remark = ''
    },
    handleQueryAppReport() {

      this.listLoading = true
      doQueryHelipayAppList(
        this.query.merchantHelipayApp,
        this.query.merchantHelipayApp.currentPage,
        this.query.merchantHelipayApp.pageSize).then(response => {

          const data = response.data
          this.query.merchantHelipayApp.total = data.totalCount
          this.query.merchantHelipayApp.pageSize = data.pageSize
          this.query.merchantHelipayApp.currentPage = data.currentPage
          this.merchantHelipayApplist = data.entities
          this.listLoading = false
        })
    },
    handleSizeChangeApp(val) {
      this.query.merchantHelipayApp.currentPage = 1
      this.query.merchantHelipayApp.pageSize = val
      this.handleQueryAppReport();
    },
    handleCurrentChangeApp(val) {
      this.query.merchantHelipayApp.currentPage = val
      this.handleQueryAppReport();
    },
    handleMerchantHelipayAppSave() {

      doEditHelipayApp(this.merchantHelipayApp).then(response => {

        console.log(response)
        const data = response.data
        if (data.status) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          this.fetchData();
        } else {
          this.$message({
            type: 'info',
            message: '操作失败!'
          })
        }
      })

    },
    handleQueryMerchantOrigin(organId, merchantId) {

      doQueryMerchantOrigins({}, organId, merchantId).then(response => {

        console.log(response)
        const data = response.data
        const merchantOrigin = {}

        if (data.length) {
          for (let i = 0; i < data.length; i++) {
            merchantOrigin[data[i].originType] = true
          }
        }
        console.log(merchantOrigin)
        this.merchantOrigin = merchantOrigin
      })
    },
    handleInitMerchantHelipayWechat() {
      this.merchantHelipayWechat.firstClassMerchantNo = this.firstClassMerchantNo
      this.merchantHelipayWechat.merchantNo = this.merchantNo
      this.merchantHelipayWechat.merchantId = this.form.id
      this.merchantHelipayWechat.organId = getOrganId()

      this.handleQueryMerchantHelipayWechat(getOrganId(), this.form.id)

    },
    handleQueryMerchantHelipayWechat(organId, merchantId) {

      doQueryHelipayWechat({}, organId, merchantId).then(response => {
        console.log(response)
        const data = response.data

        if (data) {
          this.merchantHelipayWechat = data
        }
      })
    },
    handleEditMerchantHelipayWechat() {

      //还未提交到第三方平台报备
      if (!this.merchantHelipayWechat.applySuccess) {
        doEditHelipayWechat(this.merchantHelipayWechat).then(response => {
          console.log(response)
          const data = response.data

          if (data.status) {
            this.$message({
              type: 'success',
              message: '操作成功!'
            })
            this.active++
          } else {
            this.$message({
              type: 'info',
              message: '操作失败!'
            })
          }
        })
      }

    },
    handleMerchantOriginUpload(formName) {

      this.$refs[formName].validate((valid) => {

        if (valid) {
          this.active++
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
        } else {
          this.$message({
            type: 'danger',
            message: '请检查资质文件是否都上传完毕!'
          })
        }
      })
    },
    handleQueryAndInitMerchantPayment() {
      //查询商户支付
      doQueryMerchantPayments({}, getOrganId(), this.form.id).then(response => {

        const data = response.data
        if (data.length) {
          this.merchantPaymentList = data
        } else {

          doInitMerchantPayments({
            organId: getOrganId(),
            merchantId: this.form.id,
            organPath: getOrganPath(),
            merchantNo: this.merchantEntry.merchantNo,
            firstClassMerchantNo: this.merchantEntry.firstClassMerchantNo,
            feeValueRate: this.merchantHelipay.feeValueRate,
            minFee: this.merchantHelipay.minFee
          }).then(response => {
            const data = response.data
            if (data) {
              console.log("初始化支付渠道成功")
            }
          })
        }
      })

    },
    handleMerchantEntrySubmit2ThirdPartPlatform(organId, merchantId) {

      this.listLoading = true
      doEntrySubmit({}, organId, merchantId).then(response => {

        const data = response.data
        console.log(data)
        if (data.status && data.merchantNo) {
          this.merchantEntry.merchantNo = data.merchantNo
        }
        this.listLoading = false
      })

    },
    handleMerchantOriginSubmit2ThirdPartPlatform(organId, merchantId) {

      doUploadCredential({}, organId, merchantId).then(response => {

        const data = response.data
        console.log(data)
        if (data.status && data.merchantNo) {
          this.merchantEntry.merchantNo = data.merchantNo
        }
        this.listLoading = false
      })



    },
    handleMerchantHelipayWechatSubmit2ThirdPartPlatform(organId, merchantId) {





    },
    handleMerchantHelipayAppSubmit2ThirdPartPlatform(organId, merchantId) {





    }

  }
}

</script>
